<div class="bg-light lter b-b wrapper-md">
  <h1 class="m-n font-thin h3">频道状态</h1>
</div>
<div class="wrapper-md">
  <div class="row">

   <div class="col-sm-2" >
     <!-- 左边菜单-->


     <div style=" overflow-y:auto; overflow-x:auto;  height:600px;">
       <ul id="treeDemo" class="ztree"></ul>
     </div>

   </div>

   <div class="col-sm-10">
    <div class="panel panel-default">
      <div class="panel-heading">
        频道状态
      </div>
      <div  ng-controller="dataTablesCtrl">

        <table id="myTable" class="table table-striped m-b-none">
        </table>

      </div>
    </div>
  </div>

</div>

</div>




<div id ="streamBody" style="display: none;">
  <nav ui-nav class="navi" ng-include="'src/app/channel/channelStatus/contains_stream.html'"></nav>
</div>
<input type="hidden" id="operation" name="operation">

<!--样式-->
<style type="text/css">  
  div#rMenu {position:absolute; visibility:hidden; top:0; background-color: #555;text-align: left;padding: 2px;}  
  div#rMenu a{  
    cursor: pointer;  
    list-style: none outside none;  
  }  

  .selected {
    background-color: #DFF0D8;
  }
  
  /* dataTables列内容居中 */
  .table>tbody>tr>td{
    text-align:center;
  }

  /* dataTables表头居中 */
  .table>thead:first-child>tr:first-child>th{
    text-align:center;
  }
</style>
<!--样式-->






<script type="text/javascript">




//angularjs总控制器
app.controller('dataTablesCtrl', function($scope, $http,$state) {
//进入编辑页面


});




function checkOne(){
  var optIds = '';
  $("input[name='ids']:checkbox:checked").each(function(){ 
    optIds+=$(this).val() +',';
  });
  if(''!=optIds){
    optIds = optIds.substring(0,optIds.length-1);
  }
  $('#optIds').val(optIds);

  console.log($('#optIds').val());
}





var dtUrl =  API_URL+"channel_info?query=delflag:0";



$(document).ready(function(){


 //初始化dataTable
 var table =  $('#myTable').DataTable({
   ajax: {
        url: dtUrl,  
          success:function(json){
            //清空表格
            $('#myTable').dataTable().fnClearTable();  
            if(null==json){
              $('#myTable').dataTable().fnClearTable();  
             }else{
               $('#myTable').dataTable().fnAddData(json,true);  //刷下表格
             }  
          }
        },
  deferRender:true,
  Processing:true,
  buttons: [
  {
    extend: 'collection',
    text: 'Export',
    buttons: [ 'csv-flash', 'xls-flash', 'pdf-flash' ]
  }
  ],
            //默认最后一列（最后更新时间）降序排列
            order: [[2, "desc"]],

            //行创建完成后回调
            rowCallback: function (row, data, index) {

            },
            aoColumns: [

            { data: "Id",
            title: "ID"
          },

          { data: "ChannelName"  ,
          title: "频道名称" },


          { data: "ChannelEnable" ,
          title: "状态",
          render: function (data, type, row, meta) {
            if(row.ChannelEnable==1){
              return "<i style='color:#2e8ded;' title='启用' class='fa fa-spinner fa-spin'></i>"; 
            }else{
              return "<i  title='停用' class='fa fa-spinner fa-spin'></i>";
            }
          }}

          ],
          columnDefs: [

          {
            targets:3,
            data: null,
            title: "查看流",
            render: function (data, type, row, meta) {

              var href = '';

              href += "&nbsp;  <a href='javascript:void(0);' onclick=showStream("
              + row.Id
              + ")>";
              href += "<i  title='预览' class='fa fa-video-camera'></i></a>";

              return href;

            }
          }
          ],
          drawCallback: function( settings ) {


          },

          initComplete:function(data){


          },
          Paginate: true, 
          language:{
           url: 'vendor/jquery/datatables/Chinese.json'
         }
       });
});  



// ztree 初始化

var ztreeUrl  =  API_URL+"channel_class?query=delflag:0&limit=9999&offset=0";


$(document).ready(function(){
      //初始化ztree
      onloadZTree(ztreeUrl,'频道分类' );//调用ztree-mine.js里的方法
    });

//左边ztree,onclick事件
function zTreeOnClickDetail(event, treeId, treeNode){

 var operation = $("#operation").val();
 console.log("operation:"+operation);

 var classId = treeNode.id;
 console.log(classId);
 if(classId==0){
 }

  var ztreeUrl  =   API_URL +"channel_class?query=delflag:0,id:"+classId+"&sortby=ClassDisplayOrder&order=asc&limit=9999&offset=0";
  var list = MY_ASYNC_AJAX(ztreeUrl);
  //搜索datatables
  var table = $('#myTable').DataTable();

  var newUrl =  API_URL+"channel_class/"+classId+"/channel_info";
  console.log(newUrl);

  if(0==classId){
    newUrl =  API_URL + "channel_info?query=delflag:0";
  }
  table.ajax.url(newUrl).load();

}


</script>









